package cha;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotSame;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;
import robocode.control.testing.RobotTestBed;

/**
 * Test if Destroyer is not always the first place
 * when in battle with Tracker robot.
 * 
 * the most basic robot.
 * 
 * @author Hansen Cheng
 *
 */
public class TestDestroyerVersusTracker extends RobotTestBed {

  /**
   * Specifies that SittingDuck and DaCruzer are to be matched up in this test case.
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.Tracker,cha.Destroyer";
  }
  
  /**
   * This test runs for 10 rounds.
   * @return The number of rounds. 
   */
  @Override
  public int getNumRounds() {
    return 10;
  }
  
  /**
   * Test to see if Destroyer doesn't always win against Tracker.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    BattleResults[] battleResults = event.getIndexedResults();
    BattleResults destroyerResults = battleResults[1];
    String robotName = destroyerResults.getTeamLeaderName();
    assertEquals("Check that results[1] is Destroyer", robotName, "cha.Destroyer*");
    
    assertNotSame("Check Destroyer is not winner", robotName, destroyerResults.getFirsts());
  }
  
  
  /**
   * Gets the initial position the robot starts off at.
   * 
   * @return - a list of position. Default is randomized.
   */
  @Override
  public String getInitialPositions() {
    return null;
  }
  
  /**
   * Robots starts off at random places so the
   * battle won't be deterministic.
   * 
   * @return false since robot starts off randomly.
   */
  @Override
  public boolean isDeterministic() {
    return false;
  }
}
